package cn.tedu.boot12.controller;

import cn.tedu.boot12.entity.Emp;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Classname: HelloController
 * @Author: bromide
 * @CreateTime: 2022/5/11--9:26
 * @Version: V1.0
 * @Description:
 */
@Controller
public class HelloController {
    /*@RequestMapping("/hello")
    public void hello(HttpServletResponse response, HttpServletRequest request) throws IOException {
        //设置响应类型
        response.setContentType("text/html;charset=utf-8");
        //得到输出对象
        PrintWriter pw = response.getWriter();
        //输出数据
        pw.println("服务器接收到请求!<h1>ssssss<h1>");
        //关闭资源
        pw.close();
    }*/

    @RequestMapping("/hello")
    @ResponseBody
    public String hello() {
        return "测试成功!2222";
    }

    /* @RequestMapping("/param1")
     @ResponseBody
     public String param1(HttpServletResponse response,HttpServletRequest request){
         String info = request.getParameter("info");
         return "<h1>接受到了参数:"+info+"<h1>";
     }*/
    @RequestMapping("/param2")
    @ResponseBody
    public String param2(String name, int age) {
        return "<h1> 姓名:" + name + "年龄:" + age + "<h1>";
    }

    @RequestMapping("/param3")
    @ResponseBody
    public String param3(Emp emp){
        return emp.toString();
    }
}
